/*
 * Copyright 2018-2019 KunMinX
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.wanchuang.hepos.bridge.state.home;

import androidx.databinding.ObservableField;
import androidx.lifecycle.ViewModel;
import androidx.recyclerview.widget.RecyclerView;

import com.wanchuang.architecture.utils.DateUtil;
import com.wanchuang.hepos.bridge.data.bean.ZhanDanBean;
import com.wanchuang.hepos.ui.dialog.SelectDayDialog;
import com.wanchuang.hepos.ui.dialog.SelectMonthDialog;
import com.wanchuang.hepos.ui.dialog.SelectTypeDialog;
import com.wanchuang.hepos.ui.page.adapter.ZhanDanAdapter;

import java.util.ArrayList;

/**
 * TODO tip：每个页面都要单独准备一个 statusViewModel，
 * 来托管 DataBinding 绑定的临时状态，以及视图控制器重建时状态的恢复。
 * <p>
 * 如果这样说还不理解的话，详见 https://xiaozhuanlan.com/topic/9816742350
 * <p>
 * Create by KunMinX at 19/10/29
 */
public class ZhanDanFragmentViewModel extends ViewModel {

    public final ObservableField<String> title = new ObservableField<>();
    public final ObservableField<String> year = new ObservableField<>();
    public final ObservableField<String> month = new ObservableField<>();
    public final ObservableField<String> dayFirst = new ObservableField<>();
    public final ObservableField<String> dayEnd = new ObservableField<>();
    public final ObservableField<String> type = new ObservableField<>();

    public final ObservableField<ZhanDanAdapter> adapter = new ObservableField<>();
    public final ObservableField<RecyclerView.LayoutManager> layoutManager = new ObservableField<>();
    public final ArrayList<ZhanDanBean> data = new ArrayList<>();


    public SelectDayDialog dayDialog;
    public SelectMonthDialog monthDialog;
    public SelectTypeDialog typeDialog;

    public String typeNmber ;
    public String statusNumber;
    public int page = 1;
    public int pagesize = 10;

    {
        typeNmber = "1";
        statusNumber = "1";
        title.set("账单");
        year.set(String.valueOf(DateUtil.getYear()));
        month.set(String.valueOf(DateUtil.getMonth()));
        dayFirst.set("1");
        dayEnd.set(DateUtil.getLastDayOfMonth(DateUtil.getYear(), DateUtil.getMonth()));
        type.set("全部类型");

        adapter.set(new ZhanDanAdapter(data));
    }
}
